   //初始化订单一级表格
   function initAdviceJqgrid(){
	   //$("#list1").tableDnD({scrollAmount:0}); 
	   initFind_AdviceAutocomplete();
	   initfindAdvice();
		$( "#Grop" ).buttonset();
     $("#Advice_list1").jqGrid({
   	url:'../adviceHandle/editAdvice.jsp',
	datatype: "xml",
   	colNames:['ID','留言标题','留言类型','内容','业务员', '客户','回复内容','回复人','留言时间', '回复时间'],
   	colModel:[
	    {name:'ID', width:50, sortable:false,hidden:true},
		{name:'Advice_Title', width:75, sortable:false},
		{name:'Advice_Type',index:'Advice_Type',sortable:false, width:50,},
   		{name:'Advice_Content',index:'Advice_Content', sortable:false},
		{name:'UP_ID', width:75,sortable:false,hidden:true},
		{name:'User_ID', width:75,sortable:false},
   		{name:'Advice_BackContent',editable:true , align:"left",sortable:false},
		{name:'BackUser_ID', width:70,sortable:false},	
   		{name:'Advice_AddTime',index:'Advice_AddTime', width:100},
		
   		{name:'Advice_BackTime', width:100,sortable:false },
   		
   	],
	//scroll: true,
   	rowNum:10,
   	autowidth: true,
	height:400,
   	rowList:[10,20,30],
	prmNames:{page:'page',rows:'rows',order: 'sord', search:'_search', nd:'nd', npage:null},
   	pager: jQuery('#Advice_pager1'),
	loadCompele: $( "button").button(),
	loadError:   function(xhr,stu,e){alert(xhr.responseText);},
   	sortname: 'Advice_AddTime',
    viewrecords: true,
    sortorder: "desc",
    caption:"XML Example",	
	forceFit : true, 
	cellEdit: true,
	cellsubmit: 'clientArray',
	afterEditCell: function (id,name,val,iRow,iCol){
		
	},
	afterSaveCell : function(rowid,name,val,iRow,iCol) {
		var myrow = jQuery('#Advice_list1').jqGrid('getRowData',rowid);
		ModifyAdvice(myrow.ID,myrow.User_ID,name+"="+val);
	},
	
	onSelectRow: function(id){    
      
   },   
	gridComplete: function() {
    	$( "button").button();
    }, 
	//此事件在点击表格特定单元格时发生。rowid 为行ID；iCol 为列索引；cellcontent 为单元格中内容；e 点击事件对象
	onCellSelect:function(rowid,iCol,cellcontent,e){
		if(iCol==8){
			if($(cellcontent).text()=='派送'){
				var myrow = jQuery('#Advice_list1').jqGrid('getRowData',rowid);
				
				}
			//delUser(myrow.User_ID);
			}
		},
	editurl:"../adviceHandle/editAdvice.jsp",
	
         
}).navGrid('#Advice_pager1',{edit:false,add:false,del:false,search: false });	
//jQuery("#list1").jqGrid('inlineNav',"#pager1");
	   }
	   //通过订单表的行ID获取订单ID
	   function getAdvice_Titel_By_Row(rowid){
		   var myrow = jQuery('#Advice_list1').jqGrid('getRowData',rowid);
			return myrow.Advice_Titel;
		   }
	   
//修改用户信息
function ModifyAdvice(ID,User_ID,url){
		$.ajax({
   type: "POST",
   async: false,
   dataType: "xml",
   url: "../adviceHandle/editAdvice.jsp?oper=edit",
   data: encodeURI("ID="+ID+"&User_ID="+User_ID+"&"+url),
   success: function(xmlResponse){
    //getStart(xmlResponse);
	var statuc=$(xmlResponse).find("statuc").text();	
	if(statuc=="true"){
		$("#Advice_list1").trigger("reloadGrid");
		Toalert($(xmlResponse).find('msg').text());
		
		}else{
		Toalert($(xmlResponse).find('msg').text());
		}
 	},
		error: function(XMLHttpRequest, textStatus, errorThrown) {
                        alert("status:"+XMLHttpRequest.status+"readyState:"+XMLHttpRequest.readyState+"text:"+XMLHttpRequest.responseText);
                    },
 });
	}
	
	 //格式话产品状态类型
	function Fmatter_Advice_Status(cellvalue, options, rowObject){
		  if(cellvalue=='0'){
			  //return "未确认下单";
			  return "<button >派送</button>";
		  }else if(cellvalue=='2'){
			  return "<button >派送</button>";
		  }else if(cellvalue=='2'){
			  return "已派送";
		  }else if(cellvalue=='3'){
			  return "已发货";
		  }else if(cellvalue=='4'){
			  return "已送货";
		  }else if(cellvalue=='5'){
			  return "已退货";
		  }
		}


 //添加用户提示
 function AddUserMsg(text){
	 
	 $( "#Add_User_Msg" ).text( text )
				.addClass( "ui-state-highlight" );
			setTimeout(function() {
				$( "#Add_User_Msg" ).removeClass( "ui-state-highlight", 1500 );
			}, 500 );
	 }
 function Toalert(text){
	 alert(text);
	 }
	 

//初始化搜索留言下拉菜单
function initFind_AdviceAutocomplete(){
	  $("#radio1").click(
		    function(){
				findAdvice(encodeURIComponent("意见建议"));
			}
		);	
			$("#radio2").click(
		    function(){
				findAdvice(encodeURIComponent("邀请好友"));
			}
		);	
	
		$( "#AdviceType" ).autocomplete({
			//source: "../userHandle/queryUser_Type.jsp",
			minLength: 0,
			selectedIndex:0,
			 source: function (request, response) {            
			 request.page = "1";  
			 request.rows= "100"; 
			 request.User_Name=encodeURIComponent(request.term);
			 request.User_Type="4";
				$.ajax({
					url: "../adviceHandle/searchAdviceType.jsp",
					data: request,
					dataType: "json",
					success: function( data, status ) {
					
							response( data );
						
					},
					error: function() {
					
							response( [] );
						
					}
				});
			 },
			select: function( event, ui ) {
				//log( ui.item ?
				//	"Selected: " + ui.item.value + " aka " + ui.item.id :
				//	"Nothing selected, input was " + this.value );
				//alert(ui.item.id);
				 findAdvice(encodeURIComponent(this.value));
			}
		});
		
				$( "#UPID" ).autocomplete({
			//source: "../userHandle/queryUser_Type.jsp",
			minLength: 0,
			selectedIndex:0,
			 source: function (request, response) {            
			 request.page = "1";  
			 request.rows= "100"; 
			 request.User_ID=encodeURIComponent(request.term);
			 request.User_Type="2";
				$.ajax({
					url: "../userHandle/searchUser.jsp",
					data: request,
					dataType: "json",
					success: function( data, status ) {
					
							response( data );
						
					},
					error: function() {
					
							response( [] );
						
					}
				});
			 },
			select: function( event, ui ) {
				//log( ui.item ?
				//	"Selected: " + ui.item.value + " aka " + ui.item.id :
				//	"Nothing selected, input was " + this.value );
				//alert(ui.item.id);
				 findAdvice();
			}
		});
	
				var availableTags = [
			"已处理",
			"未处理",
		];
		
		$( "#AdviceBackTime" ).autocomplete({
			delay: 0,
			minLength: 0,
			source: availableTags,
		});
		
	var dates = $( "#Start_Advice_AddTime, #End_Advice_AddTime" ).datepicker({
			defaultDate: "+1w",
			changeMonth: true,
			numberOfMonths: 1,
			onSelect: function( selectedDate ) {
				var option = this.id == "Start_Advice_AddTime" ? "minDate" : "maxDate",
					instance = $( this ).data( "datepicker" ),
					date = $.datepicker.parseDate(
						instance.settings.dateFormat ||
						$.datepicker._defaults.dateFormat,
						selectedDate, instance.settings );
				dates.not( this ).datepicker( "option", option, date );
			}
		});
	}
//初始化查询订单，指定送货按钮 
function initfindAdvice(){
			$("#find_Advice").click(
		    function(){
				//alert($("#search").serialize());
	 findAdvice();
			}
		);	
	}
	//搜索用户事件
	function findAdvice(AdviceType){
		/*获取select 选中的 text : 
	$("#ddlRegType").find("option:selected").text(); 
	获取select选中的 value: 
	$("#ddlRegType ").val(); 
	获取select选中的索引: 
	$("#ddlRegType ").get(0).selectedIndex; 
	设置select: 
	设置select 选中的索引： 
	$("#ddlRegType ").get(0).selectedIndex=index;//index为索引值*/
	//alert("userid="+$( "#userid").val()+"  username="+$( "#username").val()+"  usertype="+$( 			"#usertype").get(0).selectedIndex);
	var AdviceTitle=encodeURIComponent($( "#AdviceTitle").val());
	//var AdviceType=encodeURIComponent($( "#AdviceType").val());
	var UPID=encodeURIComponent($("#UPID").val());
	var Start_AdviceAddTime=$("#Start_Advice_AddTime").val();
	var End_AdviceAddTime=$( "#End_Advice_AddTime").val();
$("#Advice_list1").jqGrid('setGridParam',{ url: '../adviceHandle/editAdvice.jsp',
postData:{Advice_Title:AdviceTitle,Advice_Type:AdviceType,UP_ID:UPID,Start_Advice_AddTime:Start_AdviceAddTime,End_Advice_AddTime:End_AdviceAddTime},
}).trigger('reloadGrid'); 
		}

// JavaScript Document